/**
 * This file is part of the educational usermanagement system.
 * 
 * Copyright (c) 2008, Florian Arndt, Thomas Kemptner, Christian Kerl, Patrick Neuberger, Marcel Rehfeld, Emal Sadran, Stefan Sauer
 * 
 * Released under the MIT License http://www.opensource.org/licenses/mit-license.php
 */

package edu.ba.management.data.search.comparer;

import java.util.*;

/**
 * The ListEqualityComparer is the implementation of the IEqualityComparer
 * interface for the java.util.List class.
 */
public class ListEqualityComparer implements IEqualityComparer
{

    /*
     * (non-Javadoc)
     * 
     * @see edu.ba.management.data.search.comparer.IEqualityComparer#compare(java.lang.Object,
     *      java.lang.Object)
     */
    @SuppressWarnings("unchecked")
    @Override
    public boolean compare(Object value, Object reference_value)
    {
        if (List.class.isAssignableFrom(value.getClass())
                && List.class.isAssignableFrom(reference_value.getClass()))
        {

            List<Object> list1 = (List<Object>) value;
            List<Object> list2 = (List<Object>) reference_value;

            return list1.containsAll(list2);
        }

        return false;
    }

}
